home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 2 / Mac Magazin and MacEasy Magazine CD - Issue 02.iso / Themen Mac Magazin / Multimedia / Grafik-&QT Tools / NIH Image 1.53 (non-fpu) / Macros / Video < prev   
Text File  |  1994-01-14  |  6KB  |  235 lines

  1. procedure ExtractEvenField(NewWindow:boolean);
  2. {
  3. Replaces odd scan lines with average of neighboring even lines. Can be used to improve the quality of images that have even and odd fields that are out of sync as the result of subject movement during capture.
  4. }
  5. var
  6.   i,width,height,row1,row2:integer;
  7. begin
  8.   SaveState;
  9.   if NewWindow then Duplicate('Even Field');
  10.   GetPicSize(width,height);
  11.   row1:=0; row2:=0;
  12.   for i:=1 to height/2 do begin
  13.     GetRow(0,row1,width);
  14.     PutRow(0,row2,width);
  15.     row1:=row1+2;
  16.     row2:=row2+1;
  17.   end;
  18.   MakeRoi(0,0,width,height/2);
  19.   Copy;
  20.   MakeRoi(0,height/4-1,width,height/2);
  21.   Paste;
  22.   RestoreRoi;
  23.   SetScaling('Bilinear; Same Window');
  24.   ScaleAndRotate(1,2,0);
  25.   RestoreState;
  26. end;
  27.  
  28. macro 'Extract Even Field->New Window';
  29. begin
  30.   ExtractEvenField(true);
  31. end;
  32.  
  33. macro 'Extract Even Field->Same Window';
  34. begin
  35.   ExtractEvenField(false);
  36. end;
  37.  
  38.  
  39. macro 'Make Movie to Disk…';
  40. {
  41. Captures images at a specified rate and saves them to disk.
  42. Select an area of interest within the Camera window before
  43. starting. Abort at any time by pressing the mouse button.
  44. }
  45. var
  46.   nFrames,n,Left,Top,Width,Height:integer;
  47.   interval,EndTicks,secs:integer;
  48.   FirstTime:boolean;
  49. begin
  50.   GetRoi(Left,Top,Width,Height);
  51.   if width=0 then begin
  52.      PutMessage('First select the area of interest in the Camera window.');
  53.      exit;
  54.   end;
  55.   nFrames:=GetNumber('Number of Frames?',10);
  56.   secs:=GetNumber ('Delay Between Frames (seconds)?',60.0);
  57.   interval:=round(secs*60);
  58.   FirstTime:=true;
  59.   for n:=1 to nFrames do begin
  60.      StopCapturing;  beep;
  61.      MakeRoi(Left,Top,Width,Height);
  62.      SaveAs('Frame ',n);
  63.      if FirstTime then begin
  64.         EndTicks:=TickCount+interval;
  65.         FirstTime:=false;
  66.      end;
  67.      if button then begin
  68.         StopCapturing;
  69.         exit;
  70.      end;
  71.      StartCapturing;
  72.      while TickCount<EndTicks do begin
  73.          secs:=(EndTicks-TickCount) div 60;
  74.          ShowMessage(n:1,'/',nFrames,' ',secs:4)
  75.      end;
  76.      EndTicks:=EndTicks+interval;
  77.   end;
  78.   StopCapturing;
  79. end;
  80.  
  81.  
  82. macro 'Camera and Light Source Test…';
  83.   {Use to test cameras and light sources for temporal stability.}
  84. var
  85.   delay,nFrames:integer;
  86.   i:real;
  87. begin
  88.    nFrames:=trunc(GetNumber('Number of Frames:',10));
  89.    delay:=trunc(GetNumber('Delay in seconds:',10));
  90.    for I:=1 to nFrames do begin
  91.      Capture;
  92.      Measure;
  93.      SetCursor('Watch');
  94.      wait(delay);
  95.   end;
  96. end;
  97.  
  98.  
  99. macro 'Average Frames [F]';
  100. begin
  101.   AverageFrames;
  102. end;
  103.  
  104.  
  105. macro 'Average Frames on Trigger';
  106. begin
  107.   WaitForTrigger;
  108.   AverageFrames;
  109. end;
  110.  
  111.  
  112. macro 'Dynamic 1-D Plot';
  113. {
  114. Displays a dynamic 1-d plot of a line in the image while the image
  115. is being captured. You most first create a line selection in
  116. Camera window. The macro works best if you first to a Plot Profile
  117. and move the Plot window so it doesn't cover the Camera window. You
  118. may have to resize the Camera window. Hold down the mouse button
  119. to terminate.
  120. }
  121. var
  122.   x1,y1,x2,y2,LineWidth:integer;
  123. begin
  124.   GetLine(x1,y1,x2,y2,LineWidth);
  125.   if x1=-1 then begin
  126.     PutMessage('Create a straight line selection in the Camera window');
  127.     exit;
  128.   end;
  129.   SetPlotScale(0,255);
  130.   repeat
  131.     Capture;
  132.     if button then exit;
  133.     MakeLineRoi(x1,y1,x2,y2);
  134.     PlotProfile;
  135.   until button;
  136. end;
  137.  
  138.  
  139. macro 'Integrate Inverted…';
  140. {
  141. Inverts captured video to allow more than 128 frames to be
  142. integrated without overflow. For example, the sum of 256 pixels
  143. with an average value of 200(very dark) is 51,200, which is
  144. greater than the 32,767 maximum, but the sum of 256 pixels
  145. with and average value of 55(200 inverted) is 14,080.
  146. }
  147. var
  148.   nFrames:integer;
  149. begin
  150.   nFrames:=GetNumber('Number of Frames:', 200);
  151.   SetVideo('Invert');
  152.   AverageFrames('Integrate', nFrames);
  153.   SetVideo(''); {Don't invert}
  154.   Invert;
  155. end;
  156.  
  157.  
  158. macro 'Generate Pulse Train'
  159. {Outputs a 30Hz pulse train on pin 1(Data Output bit 3)}
  160. {of the Scion LG-3's utility connector.}
  161. var
  162.   NextTicks,inc:integer;
  163. begin
  164.   inc:=1; {1/60 sec.}
  165.   SetCursor('watch');
  166.   NextTicks:=TickCount+inc;
  167.   repeat
  168.     scion[4]:=BitOr(scion[4],8);
  169.     repeat until TickCount>=NextTicks;
  170.     NextTicks:=NextTicks+inc;
  171.     scion[4]:=BitAnd(scion[4],7);
  172.     repeat until TickCount>=NextTicks;
  173.     NextTicks:=NextTicks+inc;
  174.   until button;
  175. end;
  176.  
  177. macro '(-' begin end; {Menu divider}
  178.  
  179. macro 'Paste Live [L]';
  180. begin
  181.   PasteLive;
  182. end;
  183.  
  184. macro 'Paste Averaged [A]';
  185. {
  186. Captures an averaged or integrated selection into a window
  187. other than the Camera window. Use in conjunction with "PasteLive". Useful for making montages of different focal
  188. planes of fluorescent specimens.
  189. }
  190. var
  191.   x,y,width,height,pid:integer;
  192. begin
  193.   RequiresVersion(1.53);
  194.   if WindowTitle='Camera' then begin
  195.     PutMessage('The active window cannot be "Camera".');
  196.     exit;
  197.   end;
  198.   GetRoi(x,y,width,height);
  199.    if width=0 then begin
  200.     PutMessage('Rectangular selection required.');
  201.     exit;
  202.   end;
  203.   pid:=PidNumber;
  204.   SelectWindow('Camera');
  205.   MakeRoi(x,y,width,height);
  206.   AverageFrames;
  207.   Copy;
  208.   SelectPic(pid);
  209.   MakeRoi(x,y,width,height);
  210.   Paste;
  211. end;
  212.  
  213.  
  214. macro '(-' begin end; {Menu divider}
  215.  
  216. {Note: keyboard shortcuts do not work when the Video}
  217. {Control dialog box is the active window.}
  218.  
  219. macro 'SetChannel 1 [1]'; begin SetChannel(1) end;
  220. macro 'SetChannel 2 [2]'; begin SetChannel(2) end;
  221. macro 'SetChannel 3 [3]'; begin SetChannel(3) end;
  222. macro 'SetChannel 4 [4]'; begin SetChannel(4) end;
  223.  
  224. macro '(-' begin end; {Menu divider}
  225.  
  226. macro 'Set LG-3 DAC A'; begin scion[1]:=GetNumber('DAC A(0-255):',scion[1]); end;
  227. macro 'Set LG-3 DAC B'; begin scion[2]:=GetNumber('DAC B(0-255):',scion[2]); end;
  228. macro 'Set LG-3 Data Out'; begin scion[4]:=GetNumber('Data Out(0-15):',scion[4]); end;
  229. macro 'Read LG-3 Data In'; begin PutMessage('Data In=',BitAnd(scion[3],15):1); end;
  230.  
  231.  
  232.  
  233.  
  234.  
  235.